﻿Public Class COMConfigForm

    Private Sub COMConfigForm_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Init()
    End Sub

    Private Sub Init()
        For Each s As String In System.IO.Ports.SerialPort.GetPortNames
            Me.ComboBox1.Items.Add(s)
        Next

        Dim com As String
        com = KeyValuePairClass.GetValue("COMNumber")
        Me.ComboBox1.SelectedIndex = Me.ComboBox1.FindStringExact(com)

    End Sub

    Private Sub btnOK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnOK.Click
        Dim com As String
        com = Me.ComboBox1.Text.Trim()

        If com = "" Then
            msg.Show("请选择串口")
            Me.ComboBox1.Focus()
            Exit Sub
        End If

        KeyValuePairClass.SetValue("COMNumber", com)
        msg.Show("保存成功")

    End Sub

    Private Sub btnCancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCancel.Click
        Me.Close()
    End Sub


End Class